const _ = require('lodash');

const fileUtil = require('../../../utils/fileUtils');
const mqRouter = require('./routMqtt');
module.exports = class {
    constructor(app) {
        this.app = app;

    }
   async init(){
       const array = await fileUtil.readFile2json(this.app.config.infoPath + "/mqttRouter.json")
       console.log("load mqtt",array)
       this.routers = [];

       _.map(array, json => {
           const {url, port} = json;
           const router = new mqRouter(this.app);
           router.connect(url, port);
           this.routers.push(router);

       })
    }
}
